/*
   递归：相比于循环遍历而言，递归更加易于理解，易于维护。
 */


function Node(params) {
  this.value = params;
  this.next = null;
}

let a = new Node(1);
let b = new Node(2);
let c = new Node(3);
let d = new Node(4);

a.next = b;
b.next = c;
c.next = d;

//  循环遍历
function getNodevalue(node) {
  let param = node;
  while (true) {
    if (param.next == null) {
      break;
    } else {
      param = param.next;

    }
    console.log(param);
  }

}

getNodevalue(a)

//递归
function getNodevalue2(node) {
  if (node == null) return;
  console.log(node.value);
  getNodevalue2(node.next);
}

getNodevalue2(a)